﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FontDialogSample;

namespace TreeBuilder
{
	public class ChangeFontAction : UndoableAction
	{
		private readonly TreeNode _node;
		private readonly Font _font;
		private readonly Font _oldFont;
		
		public ChangeFontAction(TreeNode node, Font font)
		{
			_node = node;
			_oldFont = Font.ExtractFont(node.TextBox);
			_font = font;
		}

		public override void Execute()
		{
			Font.ApplyFont(_node.TextBox, _font);
		}

		public override void Undo()
		{
			Font.ApplyFont(_node.TextBox, _oldFont);
		}
	}
}
